using Godot;

namespace Arcane.Source.Combat.StatusEffects
{
    public class OverCharge(int duration) : TimerEffect(duration)
    {
        public readonly static StringName MODIFIER = "over_charge";
        public override void OnStack(ITrigger trigger)
        {
            if (trigger is not OverCharge other) return;

            _timer = other._timer;
        }

        public override void OnReady(Entity host)
        {
            host.AddModifier(MODIFIER, new Modifier
            {
                type = ModifierType.Hurt,
                op = ModifierOp.Mul,
                value = 0.2f,
            });
        }

        public override void OnTick(Entity host)
        {
            if ((int)_timer % 6 == 0)
            {
                host.Hurt(DamageType.Common, 1);
            }
            base.OnTick(host);
        }

        public override void OnRemove(Entity host)
        {
            host.RemoveModifier(MODIFIER);
        }
    }
}